NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

Download
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)

WHAT IS IT?

Gravity Simulator
By: Ivaylo Madzharov (2010)

This is a planetary gravity simulator, or an orbital simulator. It simulates the orbits
of stellar bodies around each other depending on factors such as mass, speed, and distance. It also simulates collision between bodies.

The main difference between this simulator and other ones on the internet is that this one is more oriented towards letting the user manipulate all aspects of the simulation. While this does make it harder to use, it gives the user endless possibilities for experimentation.

HOW IT WORKS

This model simulates gravity according to Newton's Law of Universal Gravitation. The force of gravity between two bodies is directly proportional to the product of their masses and inversely proportional to the square of the distance between them.

F = G * (m1 * m2) / (d^2)

Where F is the force, m1 and m2 are the masses of the bodies, d is the distance, and G is a universal constant.

At the core of this simulation is the calculation and addition of vectors. Each body (represented by a turtle) has a given mass, speed, and heading which are then converted into an x and y vector value. Each body also experiences a force, which is also converted into an x and y vector value. The two vectors are added and the resultant is converted back to a new speed and heading at every instance.

Collision of bodies works by adding the mass of the colliding bodies, adding the vectors of the collided bodies to result in a proper speed and heading, and making all but one of the collided bodies "disappear".

HOW TO USE IT

To start the simulation, press "Go".

To create a body, at least 3 parameters are needed. You must specify a desired mass, initial speed, and initial heading. You can then click the "Place Body with Mouse" button to put the body wherever you want on the display by clicking the mouse. Alternatively, you can specify x and y coordinates for the body to appear in. You can also choose whether or not to fix a body in place when creating it by turning "Fix?" on and off. Bodies can be later fixed and unfixed by clicking "Fix a Body" or "Unfix a Body".

To move a body, first stop the simulation. Then, turn the "Move Bodies" switch On. Select a body to move by pressing the button "Select Body to Move" and chose a body by clicking it. It will be highlighted with a hole in the middle. You can then move it about with the W A S D buttons. To start the simulation again, you must move the "Move Bodies" switch back to Off. You may not move bodies while the simulation is running.

To delete a body, you can press the "Delete with Mouse" button and select a body with your mouse to delete. To delete all the bodies at once, press "Delete All".

To go back to the original setup of a sun and one planet in circular orbit, press the button "Original Setup".

There are also several global factors which you can change. One is the absolute force of gravity. A second is the distance scale, which, as it gets bigger, makes the distance between bodies larger, which makes the effects of distance on gravity more apparent.

Lastly, trace lines and collision simulation can be turned on and off.

THINGS TO NOTICE

There are several things to notice about the effects of gravity on orbit.

Notice how planets tend to orbit around more massive bodies, and how more massive bodies are not affected as much by ones of lesser mass.

Notice how as the distance scale gets larger, the force of gravity becomes weaker over distances.

Notice how bodies with more speed are more prone to escape an orbit around other bodies.

Notice how orbits become sharper as bodies near each other, and more linear as they are farther away.

Notice how, given a relatively stable system, orbits will start to follow predictable patterns, such as the one in the original setup.

As far as the program itself, you may notice that when bodies leave the screen, they do not disappear; rather, they can come back later.

THINGS TO TRY

Try setting up a stable orbit system such as the one in the original setup. The original setup has only 1 planet, can you make a stable solar system with 2 or more planets? Could you make a stable system with 3 bodies of the same mass orbiting around a mutual center of gravity? It will take a lot of trials and perhaps some math, but it is doable.

EXTENDING THE MODEL

The one weakness of this model comes in the collision simulation. Although for 2 bodies collision works fairly well, for 3 or more bodies at the same time this is not guaranteed.

Furthermore, it would be easier for the user if a system for moving the bodies around with the mouse while the simulation is running was created. This was originally implemented, but turned out to be too glitchy.

Lastly, more preset setups of interesting orbits can always add to this model.

NETLOGO FEATURES

The NetLogo features which really are to thank for this simulation is the ability to give as many properties to turtles as you want and the ability for turtles to ask each other about their properties. The calculation of force vectors works by making every turtle ask of every other turtle their mass and position, which gives enough data to make a force vector. When this is done for every turtle, a final vector can be calculated.

RELATED MODELS

This simulation is somewhat of an improvement on the gravity simulation already in the Models Library, although at its core it is very different. The one in the Models Library simulates gravity between turtles and the ground, while this one simulates gravity between turtles.

CREDITS AND REFERENCES

The procedure for this simulation is 100% original, although it was inspired by another gravity simulator on the internet:

http://phet.colorado.edu/sims/my-solar-system/my-solar-system_en.html

(back to the NetLogo User Community Models)